﻿using FlyHorse.LIMS.IBLL;
using FlyHorse.LIMS.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FlyHorse.LIMS.BLL
{
    public partial class ReportSemiBll : BaseBll<ReportSemi>, IReportSemiBll
    {
        public List<ReportSemiResult> GetEmptResultList(string goodsID,string samplingPlaceID)
        {
            List<ReportSemiResult> resultList = new List<ReportSemiResult>();

            var standardList = this.CurrentDBSession.StandardSemiDal.LoadEntities(m => m.GoodsID == goodsID && m.SamplingPlaceID == samplingPlaceID).ToList();
            foreach (var standard in standardList)
            {
                ReportSemiResult result = new ReportSemiResult();
                result.Basis = standard.TestItem.Basis;
                result.ChineseName = standard.TestItem.ChineseName;
                result.Conclusion = "";
                result.FormOrder = standard.FormOrder;
                result.ReportSemiResultID = Guid.NewGuid().ToString();
                result.MaxValue = standard.MaxValue;
                result.MinValue = standard.MinValue;
                result.TestItemID = standard.TestItemID;
                result.TestValue = null;
                result.Unit = standard.TestItem.Unit;
                resultList.Add(result);
            }

            return resultList;
        }

        public bool DeleteSemiReport(int reportSemiID)
        {
            ReportSemi report = this.CurrentDBSession.Db.Set<ReportSemi>().Find(reportSemiID);
            if (report!=null)
            {
                this.CurrentDBSession.Db.Set<ReportSemi>().Remove(report);
                int count = this.CurrentDBSession.Db.SaveChanges();
                if (count > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
          
        }


       
    }
}
